package utils

import (
	"encoding/json"
	"io/ioutil"
	"zinx/ziface"
)

type GlobalObj struct {
	TcpServer ziface.IServer
	Host string
	TcpPort int
	Name string

	Version string
	MaxConn int
	MaxPackageSize uint32
}

var GlobalObject *GlobalObj

func (g *GlobalObj)Reload() {
	data,err := ioutil.ReadFile("conf/zinx.json")
	if err != nil {
		panic(err)
	}
	if err := json.Unmarshal(data,&GlobalObject);err != nil {
		panic(err)
	}
}

func init() {
	GlobalObject = &GlobalObj{
		TcpServer:      nil,
		Host:           "0.0.0.0",
		TcpPort:        8999,
		Name:           "ZinxServerApp",
		Version:        "V0.4",
		MaxConn:        1000,
		MaxPackageSize: 4096,
	}

	// reload file
	//GlobalObject.Reload()
}
